package com.yuwen.yuwenRPC.fault.tolerant;

/**
 * @ClassNameTolerantStrategyFactory
 * @Description TODO
 * @Author钰玟
 * @Date2025/4/6 下午1:55
 * @Version 1.0
 **/

import com.yuwen.yuwenRPC.spi.SpiLoader;

/**
 * 容错机制工厂
 */
public class TolerantStrategyFactory {

    static{
        SpiLoader.load(TolerantStrategy.class);
    }

    /**
     * 默认的容错机制-- 快速容错
     */
    private static final TolerantStrategy DEFAULT_TOLERANT_STRATEGY = new FailFastTolerantStrategy();

    /**
     * 获取容错机制
     * @param key 键名
     * @return 对应键名的容错机制
     */
    public static TolerantStrategy getInstance(String key){
        return SpiLoader.getInstance(TolerantStrategy.class, key);
    }
}
